﻿<view:AViewPage
    x:Class="OneBusAway.WP7.View.BusDirectionPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:phoneNavigation="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:data="clr-namespace:OneBusAway.WP7.ViewModel;assembly=OneBusAway.WP7.ViewModel" 
    xmlns:view="clr-namespace:OneBusAway.WP7.View;assembly=OneBusAway.WP7.View"
    xmlns:tilt="clr-namespace:ControlTiltEffect"
    tilt:TiltEffect.IsTiltEnabled="True"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource OBAForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True">

    <view:AViewPage.Resources>
        <data:BusDirectionVM x:Key="ViewModel" />
        <view:VisibilityConverter x:Key="VisibilityConverter"></view:VisibilityConverter>

        <DataTemplate x:Key="RouteDirectionTemplate">
            <Grid Margin="5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80" />
                    <ColumnDefinition Width="400" />
                </Grid.ColumnDefinitions>
                
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                <TextBlock Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Text="{Binding Path=route.shortName}" Foreground="{StaticResource OBAForegroundBrush}" FontSize="{StaticResource PhoneFontSizeLarge}" Margin="10,0,0,0" />
                <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding name}" Foreground="{StaticResource OBAForegroundBrush}" />
                <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Path=route.agency.name}" FontSize="{StaticResource PhoneFontSizeSmall}" Foreground="{StaticResource OBASubtleBrush}" />
            </Grid>
        </DataTemplate>

    </view:AViewPage.Resources>

    <!--LayoutRoot contains the root grid where all other page content is placed-->
    <Grid x:Name="LayoutRoot" Background="{StaticResource OBAPrimaryBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="24,24,0,12">
            <TextBlock x:Name="PageTitle" Text="bus direction" Margin="-3,-8,0,0" Foreground="{StaticResource OBAForegroundBrush}" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentGrid" Grid.Row="1">
            <ListBox 
                x:Name="BusDirectionListBox" 
                ItemsSource="{Binding Path=RouteDirections, Source={StaticResource ViewModel}}" 
                ItemTemplate="{StaticResource RouteDirectionTemplate}" 
                SelectionChanged="BusDirectionListBox_SelectionChanged" 
                />
        </Grid>
        
        <ProgressBar 
            Visibility="{Binding Path=Loading, Source={StaticResource ViewModel}, Converter={StaticResource VisibilityConverter}}"
            IsIndeterminate="True" 
            Height="4" 
            HorizontalAlignment="Left" 
            Name="ProgressBar" 
            VerticalAlignment="Top" 
            Width="480" 
            Style="{StaticResource PerformanceProgressBar}"
            Foreground="{StaticResource OBALightBrush}"
            
            />

    </Grid>

</view:AViewPage>
